"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const TileBox_1 = __importDefault(require("../../lib/TileTool/TileImpl/TileBox"));
const TileUtil_1 = __importDefault(require("./TileUtil"));
const Cesium = require('../../../ext/Cesium-1.130/index.js');
class TileUtilWMTS extends TileUtil_1.default {
    schemeName = 'WebMercatorTilingScheme';
    webMercatorTilingScheme;
    constructor() {
        super();
        this.webMercatorTilingScheme = new Cesium.WebMercatorTilingScheme();
    }
    getTileXYZ(lon, lat, zoom) {
        const { x, y } = this.webMercatorTilingScheme.positionToTileXY(Cesium.Cartographic.fromDegrees(lon, lat), zoom);
        return { x, y, zoom };
    }
    getRootTiles() {
        return [{ x: 0, y: 0, zoom: 0 }];
    }
    getBranchTile(xTile, yTile, zoom) {
        let list = [];
        for (let i = 0; i < 4; i++) {
            const x = xTile * 2 + (i % 2);
            const y = yTile * 2 + Math.floor(i / 2);
            const z = zoom + 1;
            list.push({ x, y, zoom: z });
        }
        return list;
    }
    tileXYZToRectangle(x, y, zoom) {
        const radiansRectangle = this.webMercatorTilingScheme.tileXYToRectangle(x, y, zoom);
        const degreeRectangle = {
            west: Cesium.Math.toDegrees(radiansRectangle.west),
            south: Cesium.Math.toDegrees(radiansRectangle.south),
            east: Cesium.Math.toDegrees(radiansRectangle.east),
            north: Cesium.Math.toDegrees(radiansRectangle.north)
        };
        const bb = new TileBox_1.default();
        bb.ymax = degreeRectangle.north;
        bb.ymin = degreeRectangle.south;
        bb.xmin = degreeRectangle.west;
        bb.xmax = degreeRectangle.east;
        return bb;
    }
    tile2lon() {
        return 0;
    }
    tile2lat() {
        return 0;
    }
}
exports.default = TileUtilWMTS;
